<?php
namespace Home\Controller;
use Admin\Model\PhotocateModel;
use Admin\Model\PhotoModel;
use Common\Model\CommonModel;
use Think\Controller;

class DyController extends Controller{

    public function index(){

        //轮播图
        $photocateModel=new PhotocateModel();
        $photoModel=new PhotoModel();
        $dat['name']='到店预约';
        $photo_cate=$photocateModel->where($dat)->find()['id'];
        if(!empty($photo_cate)){
            $arrPhoto=$photoModel->where('photo_cate='.$photo_cate)->field('pic,name')->select();
            $i=2;
            foreach($arrPhoto as $key=>$value){
                if($value['name']=='浦东店'){
                    $arrPhoto[$key]['status']=1;
                }else if($value['name']=='闵行店'){
                    $arrPhoto[$key]['status']=2;
                }else if($value['name']=='静安店') {
                    $arrPhoto[$key]['status'] = 3;
                }
                $arrPhoto[$key]['number']=$i;
                ++$i;
            }
            $arrPhoto=CommonModel::photo1($arrPhoto);
            $this->assign('arrPhoto',$arrPhoto);
        }

        //var_dump($arrPhoto);exit;
        $this->display();

    }
    public function pd(){
        $photocateModel=new PhotocateModel();
        $photoModel=new PhotoModel();

        $data['name']='浦东店';
        $photo_cate=$photocateModel->where($data)->find()['id'];
        if(!empty($photo_cate)){
            $arrBanner=$photoModel->where('photo_cate='.$photo_cate)->field('pic,name')->find();
        }
        $arrBanner=CommonModel::photo2($arrBanner);
        //var_dump($arrBanner);exit;
        $this->assign('arrBanner',$arrBanner);
        $data['name']='门店展示';
        $photo_cate=$photocateModel->where($data)->find()['id'];
        if(!empty($photo_cate)){
            $count = $photoModel->where('photo_cate='.$photo_cate)->count();
            $page= new \Think\Page($count,11);
            $page->setConfig('next','下一页');
            $page->setConfig('prev','上一页');
            //显示还有多少条
            $page->setConfig('theme','%HEADER% %FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%');
            $show = $page->show();
            $list=$photoModel->where('photo_cate='.$photo_cate)->order(array('create'=>'desc'))->limit($page->firstRow.','.$page->listRows)->field('pic,name')->select();
            $list=CommonModel::photo1($list);
            $this->assign('page',$show);
            $this->assign('list',$list);

        }

        $this->display();
    }




    public function order(){

        $IndexController= new IndexController();
        $IndexController->order();


    }


}